package cn.tutu.blockchain.controller;

import javax.validation.Valid;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.tutu.blockchain.common.MsgObj;
import cn.tutu.blockchain.wallet.entity.Wallet;
import cn.tutu.blockchain.wallet.service.WalletService;

@RestController
@RequestMapping("/wallet")
public class WalletController {

	@Autowired
	private WalletService walletService;

	@RequestMapping("/create")
	public MsgObj create(@Valid Wallet wallet) {
		walletService.create(wallet);
		return MsgObj.buildSuccessMsg();
	}

	@RequestMapping("/getByPhone")
	public MsgObj getByPhone(@NotBlank(message = "手机号不可为空") String phone) {
		Wallet wallet = walletService.getByPhone(phone);
		return MsgObj.buildSuccessMsg(wallet);
	}

}
